package com.piesat.quake.business.device.model.config.network;

import com.piesat.quake.business.device.model.ConfigurationUpdate;
import com.piesat.quake.business.device.model.NetworkData;
import com.piesat.quake.business.device.mqtt.anno.ConvertField;
import com.piesat.quake.business.device.mqtt.convert.IpConvert;

/**
 * 更新服务器配置
 */
public class UpdateConfig {
    //网络地址	Int	4B	相应通信形式的IPv4地址转换出来对应的整型值；
    @ConvertField(length = 4, convert = IpConvert.class)
    private String address;
    //网络端口	Unsigned Short	2B	相应通信形式的的IPv4端口号，范围0-65535；
    private short port;

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public short getPort() {
        return port;
    }

    public void setPort(short port) {
        this.port = port;
    }

    public NetworkData toNetWorkData() {
        NetworkData networkData = new NetworkData();
        networkData.setAddress(address);
        networkData.setPort(port);
        networkData.setType(ConfigurationUpdate.Network.UPDATE);
        return networkData;
    }

    @Override
    public String toString() {
        return "UpdateConfig{" +
                "\r\naddress='" + address + '\'' +
                ", \r\nport=" + port +
                "\r\n}";
    }
}